home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / Meta.fke < prev    next >
Encoding:
Text File  |  1996-07-03  |  5.9 KB  |  124 lines  |  [TEXT/R*ch]

  1. (* Meta -- functions for use in an interactive Moscow ML session *)
  2.  
  3. val print       : 'a -> 'a
  4. val printDepth  : int ref
  5. val printLength : int ref
  6. val installPP   : (ppstream -> 'a -> unit) -> unit
  7.  
  8. val use         : string -> unit
  9. val compile     : string -> unit
  10. val load        : string -> unit
  11. val loadOne     : string -> unit
  12. val verbose     : bool ref
  13.  
  14. val quotation   : bool ref
  15.  
  16. val quit        : unit -> 'a
  17. val system      : string -> int
  18.  
  19. (* [print e] prints the value of expression e to standard output
  20.    exactly as it would be printed at top-level, and returns the value
  21.    of e.  Output is flushed immediately.  This function is provided as
  22.    a simple debugging aid.  The effect of print is different from that
  23.    of SML/NJ print when the argument is a string, but similar to that
  24.    of Edinburgh ML.  For string arguments, the effect of SML/NJ print
  25.    can be achieved by the function BasicIO.say : string -> unit.
  26.  
  27.    [printDepth] determines the depth (in terms of nested constructors,
  28.    records, tuples, lists, and vectors) to which values are printed by
  29.    the top-level value printer and the function print.  The components
  30.    of the value whose depth is greater than printDepth are printed as
  31.    `#'.  The initial value of printDepth is 20. This value can be
  32.    changed at any moment, by evaluating, for example,
  33.        printDepth := 17;
  34.  
  35.    [printLength] determines the way in which list values are printed
  36.    by the top-level value printer and the function print.  If the
  37.    length of a list is greater than printLength, then only the first
  38.    printLength elements are printed, and the remaining elements are
  39.    printed as `...'.  The initial value of printLength is 200.  This
  40.    value can be changed at any moment, by evaluating, for example,
  41.        printLength := 500;
  42.  
  43.    [quit ()] quits Moscow ML immediately.
  44.  
  45.    [installPP pp] installs the prettyprinter pp at type ty, provided
  46.    pp has type ppstream -> ty -> unit.  The type ty must be a nullary
  47.    (parameter-less) type constructor representing a datatype, either
  48.    built-in (such as bool) or user-defined.  Whenever a value of type
  49.    ty is about to be printed by the interactive system, or function
  50.    print is invoked on an argument of type ty, the pretty-printer pp
  51.    will be invoked to print it.  See library unit PP for more
  52.    information.
  53.  
  54.    [use "f"] causes ML declarations to be read from file f as if they
  55.    were entered from the console.  A file loaded by use may, in turn,
  56.    evaluate calls to use.  For best results, use `use' only at top
  57.    level, or at top level within a use'd file.
  58.  
  59.    [compile "U.sig"] will compile and elaborate the unit signature in
  60.    file U.sig, producing a compiled signature file U.ui.  During
  61.    compilation, the compiled signatures of other units will be
  62.    accessed if they are mentioned in U.sig.
  63.  
  64.    [compile "U.sml"] will elaborate and compile the unit body in file
  65.    U.sml, producing a bytecode file U.uo.  If there is an explicit
  66.    signature U.sig, then file U.ui must exist, and the unit body must
  67.    match the signature.  If there is no U.sig, then an inferred
  68.    signature file U.ui will be produced also.  No evaluation takes
  69.    place.  During compilation, the compiled signatures of other units
  70.    will be accessed if they are mentioned in U.sml.
  71.  
  72.    The declared identifiers will be reported if verbose is true (see
  73.    below); otherwise compilation will be silent.  In any case,
  74.    compilation warnings are reported, and compilation errors abort the
  75.    compilation and raise the exception Fail with a string argument.
  76.  
  77.    [load "U"] will load and evaluate the compiled unit body from file
  78.    U.uo.  The resulting values are not reported, but exceptions are
  79.    reported, and cause evaluation and loading to stop.  If U is
  80.    already loaded, then load "U" has no effect.  If any other unit is
  81.    mentioned by U but not yet loaded, then it will be loaded
  82.    automatically before U.
  83.  
  84.    After loading a unit, it can be opened with `open U'.  Opening it
  85.    at top-level will list the identifiers declared in the unit.
  86.  
  87.    When loading U, it is checked that the signatures of units
  88.    mentioned by U agree with the signatures used when compiling U, and
  89.    it is checked that the signature of U has not been modified since U
  90.    was compiled; these checks are necessary for type safety.  The
  91.    exception Fail is raised if these signature checks fail, or if the
  92.    file containing U or a unit mentioned by U does not exist.
  93.  
  94.    [loadOne "U"] is similar to `load "U"', but raises exception Fail
  95.    if U is already loaded or if some unit mentioned by U is not yet
  96.    loaded.  That is, it does not automatically load any units
  97.    mentioned by U.  It performs the same signature checks as `load'.
  98.  
  99.    [verbose] determines whether the signature inferred by a call to
  100.    compile will be printed.  The printed signature follows the syntax
  101.    of Moscow ML signatures, so the output of compile "U.sml" can be
  102.    edited to subsequently create file U.sig.  The default value is
  103.    ref false.
  104.  
  105.    [quotation] determines whether quotations and antiquotations are
  106.    permitted in declarations entered at top-level and in files
  107.    compiled with compile.  A quotation is a piece of text surrounded
  108.    by backquote characters `a b c` and is used to embed object
  109.    language phrases in ML programs; see the Moscow ML Owner's Manual
  110.    for a brief explanation of quotations.  When quotation is false,
  111.    the backquote character is an ordinary symbol which can be used in
  112.    ML symbolic identifiers.  When quotation is {\tt true}, the
  113.    backquote character is illegal in symbolic identifiers, and a
  114.    quotation `a b c` will be recognized by the parser and evaluated to
  115.    an object of type 'a General.frag list.  The default value is ref
  116.    false.
  117.  
  118.    [system "com"] causes the command com to be executed by the
  119.    operating system.  If a non-zero integer is returned, this must
  120.    indicate that the operating system has failed to execute the
  121.    command.  Under MS DOS, the integer returned tends to always equal
  122.    zero, even when the command fails.  
  123. *)
  124.